How Do I make a joystick rotate a game object? 您所在的位置:网站首页 unity 2d object How Do I make a joystick rotate a game object?

How Do I make a joystick rotate a game object?

2023-03-22 19:32| 来源: 网络整理| 查看: 265

I have been following a tutorial to make a twin stick shooter in unity and I've gotten stuck on the rotation section of the controller. The left joystick moves the character nicely, but the right joystick which is supposed to rotate the character will only rotate the character to either 90 or -90 depending on whether or not I have the joystick above the x axis or not.

Here is the code I am using to rotate the character.

if(RightsitckInput.magnitude > 0.1f) { Vector3 curRotation = Vector3.left * RightsitckInput.x + (Vector3.up * RightsitckInput.y); Quaternion playerRotation = Quaternion.LookRotation(curRotation, Vector3.forward); rb.SetRotation(playerRotation); }



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有